<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateSgReturnTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::dropIfExists('st_sg_return');

        Schema::create('st_sg_return', function (Blueprint $table) {
            $table->increments('id');
            /* 患者信息 start */
            $table->string('EyeImageID', 64)->nullable()->comment('唯一ID');
            $table->integer('patient_id')->unsigned()->comment('患者ID');
            $table->integer('record_id')->unsigned()->comment('病例ID');
            $table->string('ImageCode', 64)->default('')->comment('是医院HIS患者对应的编号，上传图像时，把HIS中的患者号填入这里');
            $table->string('Distinguish', 20)->default('')->comment('区分：糖尿病、高血压、普通筛查、糖尿病+高血压');
            $table->string('IDCard', 20)->default('')->comment('身份证');
            $table->string('Phone', 20)->default('')->comment('手机');
            $table->string('PatientNM', 32)->default('')->comment('姓名');
            $table->tinyInteger('Age')->unsigned()->default(0)->comment('年龄');
            $table->string('Complain', 1000)->default('')->comment('主诉');
            $table->string('Sex', 10)->default('')->comment('性别:男、女');
            $table->string('PrescriptionDoctor', 32)->default('')->comment('处方医生:例如（王医生）');
            $table->integer('IntraOcularTensionLeft')->default(0)->comment('眼压（左）');
            $table->integer('IntraOcularTensionRight')->default(0)->comment('眼压（右）');
            $table->decimal('VisionLeft', 12, 2)->default('0.00')->comment('视力（左');
            $table->decimal('VisionRight', 12, 2)->default('0.00')->comment('视力（右');
            $table->decimal('CorrectedVisionLeft', 12, 2)->default('0.00')->comment('矫正视力（左)');
            $table->decimal('CorrectedVisionRight', 12, 2)->default('0.00')->comment('矫正视力（右)');
            $table->decimal('BloodSugar', 12, 2)->default('0.00')->comment('餐前血糖');
            $table->decimal('PPBloodSugar', 12, 2)->default('0.00')->comment('餐后血糖');
            $table->decimal('Weight', 12, 2)->default('0.00')->comment('体重');
            $table->string('Email', 64)->default('')->comment('邮箱');
            $table->string('Remark', 500)->default('')->comment('备注');
            /* 结论信息 start */
            $table->string('ProcessType', 64)->default('')->comment('流程类型:人工流程、自动流程');
            $table->string('EyeOffice', 10)->default('')->comment('是否转诊:否、是');
            $table->string('Suggestion', 500)->default('')->comment('建议');
            $table->string('Impression', 64)->default('')->comment('印象');
            $table->string('OriginalImg1', 100)->default('')->comment('原图1地址');
            $table->string('OriginalImgType1', 10)->default('')->comment('原图像1左眼、右眼:左、右');
            $table->string('OriginalImg2', 100)->default('')->comment('原图2地址');
            $table->string('OriginalImgType2', 10)->default('')->comment('原图像2左眼、右眼:左、右');
            $table->string('AnnotationImg1', 100)->default('')->comment('结果图1地址');
            $table->string('AnnotationImg2', 100)->default('')->comment('结果图2地址');
            /* 影像描述 start
             图像1 start */
            $table->string('C_D1', 20)->default('')->comment('');
            $table->string('DiskEdgeShape1', 20)->default('')->comment('盘沿形态');
            $table->string('A_V1', 20)->default('')->comment('A/V值');
            $table->string('MacularRegion_Hemorrhage1', 20)->default('')->comment('黄斑区出血');
            $table->string('MacularRegion_Exudation1', 20)->default('')->comment('黄斑区渗出');
            $table->string('PeripheralRetina_Hemorrhage1', 20)->default('')->comment('视网膜出血');
            $table->string('PeripheralRetina_Exudation1', 20)->default('')->comment('视网膜渗出');
            $table->string('Other1', 100)->default('')->comment('其他');
            /* 图像2 start */
            $table->string('C_D2', 20)->default('')->comment('');
            $table->string('DiskEdgeShape2', 20)->default('')->comment('盘沿形态');
            $table->string('A_V2', 20)->default('')->comment('A/V值');
            $table->string('MacularRegion_Hemorrhage2', 20)->default('')->comment('黄斑区出血');
            $table->string('MacularRegion_Exudation2', 20)->default('')->comment('黄斑区渗出');
            $table->string('PeripheralRetina_Hemorrhage2', 20)->default('')->comment('视网膜出血');
            $table->string('PeripheralRetina_Exudation2', 20)->default('')->comment('视网膜渗出');
            $table->string('Other2', 100)->default('')->comment('其他');
            /* 出血渗出 start
            出血渗出图像1 start */
            $table->string('BleedingAmount1', 100)->default('')->comment('出血数量');
            $table->decimal('BleedingArea1', 12, 2)->default('0.00')->comment('出血总面积');
            $table->decimal('BleedingMostArea1', 12, 2)->default('0.00')->comment('出血最大面积');
            $table->string('ExudeAmount1', 100)->default('')->comment('渗出数量');
            $table->decimal('ExudeArea1', 12, 2)->default('0.00')->comment('渗出总面积');
            $table->decimal('ExudeMostArea1', 12, 2)->default('0.00')->comment('渗出最大面积');
            /* 出血渗出图像2 start */
            $table->string('BleedingAmount2', 100)->default('')->comment('出血数量');
            $table->decimal('BleedingArea2', 12, 2)->default('0.00')->comment('出血总面积');
            $table->decimal('BleedingMostArea2', 12, 2)->default('0.00')->comment('出血最大面积');
            $table->string('ExudeAmount2', 100)->default('')->comment('渗出数量');
            $table->decimal('ExudeArea2', 12, 2)->default('0.00')->comment('渗出总面积');
            $table->decimal('ExudeMostArea2', 12, 2)->default('0.00')->comment('渗出最大面积');
            /* 报告pdf */
            $table->string('ReportFile', 100)->default('')->comment('报告信息（PDF）地址');
            $table->tinyInteger('report_status')->unsigned()->default(1)->comment('评估状态，默认1：开始，2：完成，3：删除');
//            $table->nullableTimestamps();
            $table->timestamp('created_at')->useCurrent()->comment('生成时间');
            $table->timestamp('updated_at')->useCurrent()->comment('更新时间');
            $table->unique('EyeImageID', 'uniq_eye_image_id');

            $table->engine = 'InnoDB';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('st_sg_return');
    }
}
